// 请求参数
type TURL_PARAMS = null | { [key: string]: Tvalue };

interface _CU_ {
    /**
     * 拼接请求地址与参数
     * @param url 请求地址
     * @param params 请求参数
     * @returns 请求地址（带参数）
     */
    splicingURL: (url: string, params?: TURL_PARAMS) => string;
}
{
    Object.defineProperty(_CU_.prototype, 'splicingURL', {
        writable: false,
        configurable: false,
        enumerable: false,
        value: U.F.overloading('Utils-splicingURL',
            {
                types: [Etype.string, [Etype.undefined, Etype.null]],
                fn: (url: string) => { return url; }
            },
            {
                types: [Etype.string, Etype.obj],
                fn: (url: string, params: any) => {
                    if (params) {
                        return url
                            + (url.includes('?') ? '&' : '?')
                            + Object.keys(params)
                                .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(String(params[key]))}`)
                                .join('&');
                    }
                    return url;
                }
            },
        )
    });
}
